<html>
<head><meta charset="utf-8"><title>normalize constants · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html">normalize constants</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="191457936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191457936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191457936">(Mar 23 2020 at 11:03)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> <span class="user-mention" data-user-id="121053">@varkor</span> I would like to work on <a href="https://github.com/rust-lang/rust/issues/70125#issuecomment-602133708" target="_blank" title="https://github.com/rust-lang/rust/issues/70125#issuecomment-602133708">https://github.com/rust-lang/rust/issues/70125#issuecomment-602133708</a><br>
as it seems like this is needed to fix <a href="https://github.com/rust-lang/rust/issues/63695" target="_blank" title="https://github.com/rust-lang/rust/issues/63695">https://github.com/rust-lang/rust/issues/63695</a></p>
<p>As I don't yet understand what exactly has to be done here  I need some guidance.<br>
In case you don't have enough time for this I would just work on something else for now.</p>



<a name="191464268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191464268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191464268">(Mar 23 2020 at 12:15)</a>:</h4>
<p>the first one is the important one, in <code>src/librustc/ty/normalize_erasing_regions.rs</code></p>



<a name="191464335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191464335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191464335">(Mar 23 2020 at 12:16)</a>:</h4>
<p>basically you can add <code>normalize_const_after_erasing_regions</code>, or maybe even better generalize <code>normalize_ty_after_erasing_regions</code> to <code>normalize_generic_rg_after_erasing_regions</code> and make it take <code>GenericArg&lt;'tcx&gt;</code> instead of <code>Ty&lt;'tcx&gt;</code></p>



<a name="191464388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191464388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191464388">(Mar 23 2020 at 12:16)</a>:</h4>
<p>then you can have a <code>fold_const</code> just like <code>fold_ty</code></p>



<a name="191464532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191464532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191464532">(Mar 23 2020 at 12:17)</a>:</h4>
<p>which makes me wonder, how many <code>fold_ty</code>s and <code>visit_ty</code> there are that are missing a <code>fold_const</code>/<code>visit_const</code></p>



<a name="191471737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191471737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191471737">(Mar 23 2020 at 13:23)</a>:</h4>
<p>I don't quite know what <code>normalize_const_after_erasing_regions</code> should do. <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> </p>
<p>My guess is:</p>
<ul>
<li>normalize <code>constant.ty</code>(currently already done implicitly due to <code>fold_ty</code> afaict)</li>
<li>? evaluate the constant ?</li>
</ul>



<a name="191471889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191471889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191471889">(Mar 23 2020 at 13:25)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> you don't have to do anything yourself</p>



<a name="191471909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191471909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191471909">(Mar 23 2020 at 13:25)</a>:</h4>
<p>the query just exists to cache things</p>



<a name="191472139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191472139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191472139">(Mar 23 2020 at 13:27)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> all of this code should compile even if <code>ty: Ty</code> is replaced with <code>ct: Const</code> basically <a href="https://github.com/rust-lang/rust/blob/131772c5e0ba40cd656dedb5e1990d36e3ea31cf/src/librustc_traits/normalize_erasing_regions.rs#L13-L39" target="_blank" title="https://github.com/rust-lang/rust/blob/131772c5e0ba40cd656dedb5e1990d36e3ea31cf/src/librustc_traits/normalize_erasing_regions.rs#L13-L39">https://github.com/rust-lang/rust/blob/131772c5e0ba40cd656dedb5e1990d36e3ea31cf/src/librustc_traits/normalize_erasing_regions.rs#L13-L39</a></p>



<a name="191472175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191472175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191472175">(Mar 23 2020 at 13:27)</a>:</h4>
<p>most of the infrastructure is just generic code built on visitable/foldable types</p>



<a name="191472628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191472628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191472628">(Mar 23 2020 at 13:31)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> anyway if you take my second suggestion and generalize the <code>Ty</code> form to <code>GenericArg</code>, that will result in no code duplication</p>



<a name="191475372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191475372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191475372">(Mar 23 2020 at 13:52)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> so I looked at all <code>fold_ty</code>s and it looks like the only one that's missing a <code>fold_const</code> counterpart is in <code>normalize_erasing_regions</code>, and I'll let you handle it</p>



<a name="191478785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191478785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191478785">(Mar 23 2020 at 14:18)</a>:</h4>
<p>opened <a href="https://github.com/rust-lang/rust/issues/70317" target="_blank" title="https://github.com/rust-lang/rust/issues/70317">#70317</a></p>



<a name="191485164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191485164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191485164">(Mar 23 2020 at 15:00)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> My current WIP causes a strange failure which I don't fully understand. <a href="https://github.com/rust-lang/rust/pull/70319" target="_blank" title="https://github.com/rust-lang/rust/pull/70319">https://github.com/rust-lang/rust/pull/70319</a></p>
<p>I will try and look into it in more detail later.</p>



<a name="191485895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191485895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191485895">(Mar 23 2020 at 15:05)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> the ICE? that looks like something I was explaining on some issue that we should ban for now because it's impossible to support</p>



<a name="191486139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191486139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191486139">(Mar 23 2020 at 15:06)</a>:</h4>
<p>ah no the builtins thing</p>



<a name="191486215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191486215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191486215">(Mar 23 2020 at 15:07)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> it's possible the builtins thing is because of the second half of <a href="https://github.com/rust-lang/rust/issues/70125#issuecomment-602133708" target="_blank" title="https://github.com/rust-lang/rust/issues/70125#issuecomment-602133708">https://github.com/rust-lang/rust/issues/70125#issuecomment-602133708</a></p>



<a name="191486728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191486728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191486728">(Mar 23 2020 at 15:10)</a>:</h4>
<p>basically there is missing symmetry between <code>visit_ty</code> and <code>visit_const</code></p>



<a name="191496210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191496210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191496210">(Mar 23 2020 at 16:09)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/normalize.20constants/near/191464532" title="#narrow/stream/182449-t-compiler.2Fhelp/topic/normalize.20constants/near/191464532">said</a>:</p>
<blockquote>
<p>which makes me wonder, how many <code>fold_ty</code>s and <code>visit_ty</code> there are that are missing a <code>fold_const</code>/<code>visit_const</code></p>
</blockquote>
<p>I did audit the <code>fold_ty</code> and <code>visit_ty</code>s at one point, either adding the <code>*_const</code> version, or at least adding <code>FIXME(const_generics)</code> comments<br>
however, that's not to say that more have been added in the interim without accompanying const versions (or that I didn't miss a few)</p>



<a name="191500199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191500199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191500199">(Mar 23 2020 at 16:34)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span> see <a href="https://github.com/rust-lang/rust/issues/70317" target="_blank" title="https://github.com/rust-lang/rust/issues/70317">#70317</a></p>



<a name="191518944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191518944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191518944">(Mar 23 2020 at 18:46)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/70319" target="_blank" title="https://github.com/rust-lang/rust/pull/70319">https://github.com/rust-lang/rust/pull/70319</a> should now be ready for review again</p>



<a name="191526025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191526025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191526025">(Mar 23 2020 at 19:43)</a>:</h4>
<p>I don't have anything to do now <span aria-label="shock" class="emoji emoji-1f628" role="img" title="shock">:shock:</span> are some some topics/ issues which I can work on?</p>



<a name="191539005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191539005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191539005">(Mar 23 2020 at 21:27)</a>:</h4>
<p>how can I add a span to a cycle error?</p>



<a name="191539686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/normalize%20constants/near/191539686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/normalize.20constants.html#191539686">(Mar 23 2020 at 21:32)</a>:</h4>
<p>use <code>tcx.at(span).your_query</code> when calling a query</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>